<?php

namespace App\Admin\Forms\Settings;

use Encore\Admin\Widgets\Form;
use Illuminate\Http\Request;

class Website extends BaseTabForm
{
	/**
	 * The form title.
	 *
	 * @var string
	 */
	public $title = '网站设置';
	
	/**
	 * Handle the form request.
	 *
	 * @param Request $request
	 *
	 * @return \Illuminate\Http\RedirectResponse
	 */
	public function handle(Request $request)
	{
		//		dump($request->all());
		parent::handle($request);
		admin_success('Processed successfully.');
		
		return back();
	}
	
	/**
	 * Build a form here.
	 */
	public function form()
	{
		$this->text('web_name', '网站名')->rules('required');
		$this->text('web_keyword', '网站关键词');
		$this->textarea('web_description', '网站描述');
		$this->radio('web_status', '网站状态')->options([0 => '关闭', 1 => '开启'])->stacked();
//		$this->switch('web_status', '网站状态');
		$this->text('web_icp_number', '网站备案号');
		$this->text('web_title', '网站标题');
		$this->email('email', '管理员邮箱');
	}
	
	/**
	 * The data of the form.
	 *
	 * @return array $data
	 */
	public function data()
	{
		return [
			'web_name'        => sys('web_name'),
			'web_keyword'     => sys('web_keyword'),
			'web_description' => sys('web_description'),
			'web_status'      => sys('web_status'),
			'web_icp_number'  => sys('web_icp_number'),
			'web_title'       => sys('web_title'),
			'email'           => sys('name'),
		];
	}
}